// ignore_for_file: deprecated_member_use

import 'package:flutter/material.dart';
import 'package:getx/custom/customappbar.dart';
// ignore: import_of_legacy_library_into_null_safe
import 'package:get/get.dart';

// ignore: must_be_immutable
class SnackbarGetX extends StatefulWidget {
  String name;
  SnackbarGetX({Key? key, required this.name}) : super(key: key);
  @override
  _SnackbarGetXState createState() => _SnackbarGetXState();
}

class _SnackbarGetXState extends State<SnackbarGetX> {
  void _snackbar() {
    Get.snackbar(
      '标题部分',
      "内容部分",
      colorText: Colors.white,
      backgroundColor: Colors.black12,
      duration: const Duration(seconds: 3),
      snackPosition: SnackPosition.BOTTOM,
      titleText: const Text(
        '自定义新标题部分',
        textAlign: TextAlign.center,
        style: TextStyle(
          fontSize: 20,
          color: Colors.white54,
        ),
      ),
      messageText: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: const [
          Text(
            '自定义新内容部分',
            style: TextStyle(
              fontSize: 20,
              color: Colors.white54,
            ),
          ),
          ListTile(
            leading: Icon(Icons.ac_unit), // 左侧图标按钮
            title: Text('标题'),
            subtitle: Text('副标题'),
            trailing: Icon(Icons.add), // 右侧图标按钮
          )
        ],
      ),
      borderColor: Theme.of(context).primaryColor,
      borderWidth: 2.0,
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: CustomAppbar(widget.name, Theme.of(context).primaryColor),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            RaisedButton(
              onPressed: _snackbar,
              child: Text(
                widget.name,
                style: const TextStyle(
                  fontSize: 20,
                  color: Colors.white,
                ),
              ),
            )
          ],
        ),
      ),
    );
  }
}
